package org.td.engine.entity;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public abstract class Building extends Entity {
    
    protected int width;
    protected int height;
    
    public Building(EntityEnvironment environment, BuildingClass buildingClass) {
        super(environment, buildingClass);
        this.width = buildingClass.getWidth();
        this.height = buildingClass.getHeight();
    }

    @Override
    public void render(SpriteBatch batch) {
        sprite.render(batch, x, y, false);
    }
    
    public int getWidth() {
        return width;
    }
    
    public int getHeight() {
        return height;
    }

    public boolean containsPoint(int x, int y) {
        int scaledWidth = environment.getCellWidth() * width;
        int scaledHeight = environment.getCellHeight() * height;

        if (x > this.x && x < this.x + scaledWidth && y > this.y && y < this.y + scaledHeight) {
            return true;
        }  else {
            return false;
        }
    }

    public float getCenterX() {
        return environment.getCellWidth() * width / 2f + x;
    }

    public float getCenterY() {
        return environment.getCellHeight() * height / 2f + y;
    }
}
